package com.bjy.qa.entity.performancetest;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bjy.qa.entity.BaseEntity;
import com.bjy.qa.enumtype.CatalogType;
import com.bjy.qa.enumtype.PerfLogType;
import com.bjy.qa.enumtype.RunStatus;
import com.bjy.qa.util.EnumUtil;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Index;
import com.gitee.sunchenbin.mybatis.actable.annotation.TableComment;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@TableName("pt_test_result_log")
@TableComment("性能测试结果日志表")
@ApiModel("性能测试结果日志 Entity 模型")
public class PerfTestResultLog extends BaseEntity<PerfTestResultLog> {
    @TableField(exist = false)
    @ApiModelProperty(value = "分类类型 - 上报日志类型", example = "1")
    CatalogType ctype;

    @Column(type = MySqlTypeConstant.INT, comment = "性能测试日志类型")
    @ApiModelProperty(value = "性能测试日志类型", example = "1")
    PerfLogType logType;

    @Column(isNull = false, comment = "测试结果 id")
    @ApiModelProperty(value = "测试结果 id", example = "1")
    @Index(columns = "result_id, test_script_id")
    Long resultId;

    @Column(isNull = false, comment = "测试脚本 id")
    @ApiModelProperty(value = "测试脚本 id", example = "1")
    Long testScriptId;

    @Column(length=100, comment = "描述")
    @TableField("`desc`")
    @ApiModelProperty(value = "描述", example = "执行成功！")
    String desc;

    @Column(isNull = false, length=100, comment = "类型(等待、休眠)")
    @ApiModelProperty(value = "类型(等待、休眠)", example = "等待")
    String type;

    @Column(isNull = false, type = MySqlTypeConstant.LONGTEXT, comment = "日志信息")
    @ApiModelProperty(value = "日志信息", example = "进入房间")
    String log;

    @Column(isNull = false, type = MySqlTypeConstant.INT, comment = "状态")
    @ApiModelProperty(value = "状态", example = "1")
    RunStatus status;

    @Column(isNull = false, length=10, comment = "msg (step、status)")
    @ApiModelProperty(value = "msg (step、status)", example = "status")
    String msg;

    public void setStatus(int status) {
        this.status = EnumUtil.valueOf(RunStatus.class, status);
    }

    public void setCtype(int type) {
        this.ctype = EnumUtil.valueOf(CatalogType.class, type);
    }

    public void setLogType(int type) {
        this.logType = EnumUtil.valueOf(PerfLogType.class, type);
    }
}
